# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=eyewitness
pkgver=1225.68fead0
pkgrel=2
groups=('blackarch' 'blackarch-webapp' 'blackarch-recon' 'blackarch-misc')
pkgdesc='Designed to take screenshots of websites, provide some server header info, and identify default credentials if possible.'
arch=('any')
url='https://github.com/ChrisTruncer/EyeWitness'
license=('GPL3')
depends=('python' 'python-pyqt4' 'python-netaddr' 'ghost-py' 'python-rdpy'
         'python-selenium' 'python-rsa' 'xorg-server-xvfb'
         'python-beautifulsoup4' 'python-pyvirtualdisplay'
         'python-fuzzywuzzy' 'python-pillow' 'geckodriver' 'firefox'
         'python-easyprocess' 'python-pytesseract')
makedepends=('git')
source=("$pkgname::git+https://github.com/FortyNorthSecurity/EyeWitness.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  grep -iRl 'python' * | xargs sed -i 's|python$|python|'
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md CHANGELOG
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md CHANGELOG LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec python /usr/share/$pkgname/Python/EyeWitness.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

